<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::patterns([
    'id' => '[1-9][0-9]*',
]);

Route::group(['middleware' => ['web']], function () {
    // web route todo
});

Route::group(['middleware' => ['api'], 'prefix' => 'v1'], function () {
    // api 'throttle:60,1' 是可以在后面被覆盖的
    Route::post('oauth/access_token', 'OAuthController@postAccessToken');
    // api route todo
    Route::get('articles', 'IndexController@index');
    // 文章详情
    Route::get('articles/{id}', 'ArticleController@show');
    // 注册用户
    Route::post('users', 'UserController@store');
    // 用户登录 post /v1/oauth/access_token
    // 用户收藏文章
    Route::put('articles/{id}/stars', 'ArticleController@star');
    // 用户取消收藏文章
    Route::delete('articles/{id}/stars', 'ArticleController@unstar');
    // 文章评论
    Route::post('articles/{id}/comments', 'ArticleController@comment');
    // 文章评论列表
    Route::get('articles/{id}/comments', 'ArticleController@commentList');
    // 文章评论点赞
    Route::put('articles/{id}/comments/{comment_id}/favours', 'CommentController@favour');
    // 文章评论取消点赞
    Route::delete('articles/{id}/comments/{comment_id}/favours', 'CommentController@unfavour');
    // 评论回复
    Route::post('comments/{comment_id}/replies', 'CommentController@reply');
    // 标签
    Route::get('tags', 'CommunityController@tag');
    // 报告
    Route::get('reports', 'ArticleController@report');
    // 搜索文章
    Route::get('search/articles', 'ArticleController@search');
    Route::get('products', 'IndexController@product');
    // 获取用户信息
    Route::get('user', 'UserController@profile');
    // 我的评论
    Route::get('user/comments', 'UserController@myComment');
});
